﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OnLineExam.Web.mag
{
    /// <summary>
    /// GetCourseHandler 的摘要说明
    /// </summary>
    public class GetCourseHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string type = context.Request.Params["type"];
            OnLineExam.BLL.Course bll = new OnLineExam.BLL.Course();
            switch (type)
            {
                case "getlist":
                    #region 获取列表
                    //int page = int.Parse(context.Request.Params["page"]);
                    //int rows = int.Parse(context.Request.Params["rows"]);
                    string depid = context.Request.Params["depid"];
                    //int startIndex = (page - 1) * rows + 1;
                    //int endIndex = (page) * rows;

                    //var loginuser=new UserManager().GetModel(context.User.Identity.Name);
                    var ds = bll.GetList("depid=" + depid);
                    int RecordCount = ds.Tables[0].Rows.Count;
                    context.Response.Write(HHG.Common.Json.DataTable2Json(ds.Tables[0], false));
                    #endregion
                    break;
                case "edit":
                    #region 根据ID获取信息
                    var ID = context.Request.Params["ID"];
                    if (!string.IsNullOrEmpty(ID))
                    {
                        var m = bll.GetModel(int.Parse(ID));
                        var rsult = HHG.Common.Json.GetJson<OnLineExam.Model.Course>(m);
                        context.Response.Write(rsult);
                    }

                    #endregion
                    break;
                case "editsave":
                    var dd = "";
                    break;
                default:
                    break;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}